﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace coliseu.BussinessLayer
{
    public class BlocoBL
    {
       private coliseuEntities cEntities;

       public BlocoBL()
        {
            cEntities = new coliseuEntities(Properties.Settings.Default.conn_coliseu);
        }

        public List<bloco> selecionar()
        {
            return (from x in cEntities.bloco select x).ToList();
        }

        public List<bloco> selecionar(string descricao)
        {
            return (from x in cEntities.bloco where x.descricao.Contains(descricao) select x).ToList();
        }

        public void salvar(bloco b, string tipo)
        {

            if (tipo == "insert")
            {
                cEntities.AddTobloco(b);
            }
            else
            {
                cEntities.bloco.ApplyCurrentValues(b);
            }
            cEntities.SaveChanges();
        }

        public void excluir(bloco b)
        {            
            cEntities.bloco.DeleteObject(b);
            cEntities.SaveChanges();
        }
    }
}
